<?php

require '../conn.php';

require 'config.php';

require '../inc/function.php';

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title></title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link rel="stylesheet" href="../css/admin.css" type="text/css" />

<script type="text/javascript" src="inc/function.js"></script>

</head>

<body>

<?php

switch($act){

case 'delete':

	mysql_query('delete from '.$language.'_pro where n_id='.$id);

	Msg('','Referer');

	break;

case 'deletes':

	DeleteDatas('delete from '.$language.'_pro where n_id');

	break;

case 'index';

	mysql_query('update '.$language.'_pro set n_index=1 where n_id='.$id);

	Msg('','Referer');

	break;

case 'unindex':

	mysql_query('update '.$language.'_pro set n_index=0 where n_id='.$id);

	Msg('','Referer');

	break;

}

?>

<div id="container">

	<input type="text" id="search_key" class="search_input" size="30" value="<?php echo  $search_key ?>" />

	<input type="button" name="button" class="search_button" value="搜 索" onclick="location.href='?search_key='+$('search_key').value" />

<select id="n_class" onchange="ChangeClass(this.value);" >
            	<option value="0" <?php if($row['n_sid']==0) {?> elected="selected" <?php }?>>无</option>
                	<?php

			$query=mysql_query('select * from '.$language.'_pro_class where n_sid=0 order by n_order,n_id');

			if (mysql_num_rows($query)>0){

			while($row=mysql_fetch_array($query)){
			?>
       
           <option value="<?php echo $row['n_id']?>" ><?php echo $row['n_name']?></option>
            
				<?php
                $query2=mysql_query('select * from '.$language.'_pro_class where n_sid='.$row['n_id'].' order by n_order,n_id');
    
                if (mysql_num_rows($query2)>0){
    
                while($row2=mysql_fetch_array($query2)){
                ?>
                <option value="<?php echo $row2['n_id']?>" >&nbsp;&nbsp;--<?php echo $row2['n_name']?></option>
                
         
                    <?php
                   
				 
 
                }
    
                }

    
			}

			}

			

			?>
            </select>
	<?php

	$str='';

 

	if ($meter!=''){

		$str.='<script type="text/javascript">$("n_class").value="'.$meter.'";</script>';

		$sqls=' and n_class='.$meter;

	}

	if ($search_key!='') $sqls=" and n_title like '%{$search_key}%'";

	echo $str;

	?>

	<div class="view" style="margin-top:5px;">

		<h1>产品管理<a href="javascript:location.reload();">刷新</a></h1>

		<form name="form1" id="form1" method="post" action="?act=deletes&<?php echo $urls ?>">

	    <table width="100%" border="0" cellpadding="0" cellspacing="0">

        	<tr class="v_title">

            	<td width="7%">ID号</td>

                <td width="13%">产品分类</td>

				<td width="43%">产品标题</td>

                <td width="11%">首页推荐</td>
                <td width="9%">排序</td>

				<td width="17%">操作</td>

        	</tr>

			<?php

			$str='';

			$page_size=30;

			$page_sql='select n_id,n_class,n_index,n_order,n_title,n_date from '.$language.'_pro where 1=1'.$sqls.' order by n_order , n_id';

			$page_count=GetPageCount($page_size,$page_sql);

			if ($page>$page_count) $page=$page_count;

			$page_number=($page-1)*$page_size;

			$query=mysql_query($page_sql." limit $page_number,$page_size");

			if (mysql_num_rows($query)>0){

			while($row=mysql_fetch_array($query)){

				$str.='<tr onmouseover="this.className=\'view_trover\';" onmouseout="this.className=\'view_trout\';">';

				$str.='<td><input type="checkbox" name="checkbox[]" value="'.$row['n_id'].'" align="absmiddle" />&nbsp;'.$row['n_id'].'</td>';

				$str.='<td>'.RsField('select n_name from '.$language.'_pro_class where n_id='.$row['n_class']).'</td>';

				$str.='<td><a href="../showpro.php?id='.$row['n_id'].'" target="_blank">'.$row['n_title'].'</a></td>';

 	
					if($row['n_index']==0)
				{
					$str.='<td style="line-height:17px;"><a href="?act=index&id='.$row['n_id'].'">推荐</a></td>';
					}
				else
				{
				$str.='<td style="line-height:17px;"><a href="?act=unindex&id='.$row['n_id'].'"><font style="color:#f00">取消推荐</font></a></td>';

					}
				
				$str.='<td><div class="inputorder" id="inputorder_'.$row['n_id'].'" contenteditable="true" onblur="Ordern(\'pro\','.$row['n_id'].')">'.$row['n_order'].'</div></td>';
 
				$str.='<td><a href="pro_modify.php?'.$urls.'&id='.$row['n_id'].'">修改</a> | <a href="?act=delete&id='.$row['n_id'].'" onclick="return ConfirmDel();">删除</a></td>';

				$str.='</tr>';

			}

			}

			else {

				$page_show=false;

			}

			echo $str;

			?>

		</table>

		</form>

		<?php if($page_show) echo ShowPage($page,$page_size,$page_sql); ?>

	</div>

</div>

</body>

</html>